//
//  SupportCategoryGoodListModel.m
//  quxiangtao
//
//  Created by xbmios on 2018/10/8.
//  Copyright © 2018年 shanhaijin. All rights reserved.
//

#import "SupportCategoryGoodListModel.h"

@implementation SupportCategoryGoodListModel

+ (NSDictionary *)mj_replacedKeyFromPropertyName
{
    return @{@"goodId": @"id"};
}

+ (void)supprotGoodListWithPage:(NSInteger)page andClassID:(NSString *)classID SortId:(NSString *)sortId successBlock:(HttpRequestSuccess)successBlock failBlock:(HttpRequestFailed)failBlock {
    
    NSString *str = [NSString stringWithFormat:@"{\"classid\" : \"%@\", \"sort_id\" : \"%@\", \"page\" : \"%@\", \"number\" : \"%@\"}", [RSA encryptString:classID publicKey:PublicKey], [RSA encryptString:sortId publicKey:PublicKey],[RSA encryptString:[NSString stringWithFormat:@"%zd", page] publicKey:PublicKey], [RSA encryptString:@"10" publicKey:PublicKey]];
    
    [PPNetworkHelper POST:@"goods/Qxtgoods/goodsList" parameters:@{@"json" : str} success:^(id responseObject) {
        
        NSLog(@"自营商品分类商品列表%@", responseObject);
        
        NSArray *array = responseObject[@"data"];
        
        NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithDictionary:responseObject];
        
        if (array.count > 0) {
            
            NSArray *modelArr = [SupportCategoryGoodListModel mj_objectArrayWithKeyValuesArray:array];
            
            [dict removeObjectForKey:@"data"];
            [dict setObject:modelArr forKey:@"data"];
            
        }
        
        if (successBlock) {
            
            successBlock(dict);
            
        }
        
    } failure:^(NSError *error) {
        
        if (failBlock) {
            
            failBlock(error);
        }
        
    }];
    
}

@end
